import 'package:demo1/provider/_providers.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../provider/chatdetailprovider.dart';


class ChatdetailBarUI extends ConsumerWidget {

  ChatdetailBarUI({super.key,required this.chatDetailProvider});

  ChangeNotifierProvider<ChatDetailProvider> chatDetailProvider;

  bool isOnline =  false;


  @override
  Widget build(BuildContext context, WidgetRef ref) {

    return Consumer(
        builder: (context, ref, child) {


          return Container(
            padding: EdgeInsets.only(right: 16),
            child: Row(
              children: <Widget>[
                SizedBox(
                  width: 2,
                ),
                CircleAvatar(
                  backgroundImage:
                  AssetImage(ref.read(chatDetailProvider).conversation.avatar),
                  maxRadius: 20,
                ),
                SizedBox(
                  width: 12,
                ),
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Text(
                        ref.read(chatDetailProvider).conversation.title,
                        style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
                      ),
                      SizedBox(
                        height: 6,
                      ),
                      Text(
                        isOnline?"在线":"离线",
                        style: TextStyle(color: Colors.grey.shade600, fontSize: 13),
                      ),
                    ],
                  ),
                ),
                Icon(
                  Icons.settings,
                  color: Colors.black54,
                ),
              ],
            ),
          );


        }
    );




  }
}
